package com.dream.service.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.dream.able.ReplyMapper;
import com.dream.datasource.DBContextHolder;
import com.dream.pojo.Reply;
import com.dream.service.able.All_Service_able;


/*
 * 文章评论回复的业务类
 */
@Service("Reply_Serviceimpl")
public class Reply_Serviceimpl implements All_Service_able<Reply> {

	
	/*
	 * 文章回复表DAO代理对象
	 */
	@Resource(name="replyMapper")
	private ReplyMapper reply_mapper;
	
	/*
	 * (添加一条回复)
	 * @see com.dream.service.able.All_Service_able#insert(java.lang.String[])
	 */
	@Override
	public Reply insert(String... str) {
		//切换数据源,主库
		DBContextHolder.setDbType(DBContextHolder.master);
		//创建回复对象
		Reply reply = new Reply();
		//插入用户id
		reply.setUid(Integer.parseInt(str[0]));
		//插入时间
		reply.setTime(new Date());
		//插入回复内容
		reply.setContext(str[1]);
		//插入评论id
		reply.setCid(Integer.parseInt(str[2]));
		//插入状态
		reply.setState(1);
		//将对象写入数据库
		return reply_mapper.insertSelective(reply)>0?reply:null;
	}

	@Override
	public List<Reply> list() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Reply getT(String... str) {
		// TODO Auto-generated method stub
		return null;
	}

}
